#include "stdafx.h"
#include "McHighwayHollowPierArx.h"
#include "json/json.h"
#include "McHighwayHollowPierData.h"
#include "McElement3dDrawer.h"
#include "DrawHighwayCmd.h"

void McHighwayHollowPierArx::drawHighwayHollowPier(const CAtlString& json)
{
	Json::Reader reader;
	Json::Value resp;

	std::string str = CT2A(json.GetString());
	reader.parse(str, resp, false);

	McHighwayHollowPierData data;
	data.height = resp["Height"].asDouble();
	data.width = resp["Width"].asDouble();
	data.length = resp["Length"].asDouble();
	data.thickness = resp["Thickness"].asDouble();
	data.gradientWidth = resp["GradientWidth"].asDouble();
	data.gradientHeight = resp["GradientHeight"].asDouble();
	data.topSolidHeight = resp["TopSolidHeight"].asDouble();
	data.bottomSolidHeight = resp["BottomSolidHeight"].asDouble();

	data.pierCorner.type = (CornerType)resp["PierCorner"]["Type"].asInt();
	data.pierCorner.radius = resp["PierCorner"]["Radius"].asDouble();
	data.pierCorner.length = resp["PierCorner"]["Length"].asDouble();
	data.pierCorner.height = resp["PierCorner"]["Height"].asDouble();

	data.hollowCorner.type = (CornerType)resp["HollowCorner"]["Type"].asInt();
	data.hollowCorner.radius = resp["HollowCorner"]["Radius"].asDouble();
	data.hollowCorner.length = resp["HollowCorner"]["Length"].asDouble();
	data.hollowCorner.height = resp["HollowCorner"]["Height"].asDouble();

	Mc3dHighwayHollowPierDrawer drawer;
	drawer.setData(&data);

	DrawHighwayCmd cmd(&drawer);
	cmd.execute();

	ArxGraph::UpdateGraph();
}
